package com.dsr.controller;

import com.dsr.consts.Result;
import com.dsr.entity.Shop;
import com.dsr.service.ShopService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * (Shop)表控制层
 *
 * @author dsr
 * @since 2020-10-08
 */
@Api(tags = "(Shop)表控制层")
@RestController
@RequestMapping("/shop")
public class ShopController {

    @Autowired
    private ShopService shopService;


    @ApiOperation("保存操作")
    @ApiParam(name = "shop", value = "实体", required = true)
    @PostMapping("/save")
    public Result save(@RequestBody Shop shop) {
        return shopService.save(shop);
    }

    @ApiOperation("更新操作")
    @ApiParam(name = "shop", value = "实体", required = true)
    @PutMapping("/update")
    public Result update(@RequestBody Shop shop) {
        return shopService.update(shop);
    }

    @ApiOperation("根据id删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id(ps:1,2,3)", required = true)
    })
    @DeleteMapping("/delete")
    public Result delete(@RequestBody String id) {
        return shopService.delete(id);
    }


    @ApiOperation("返回所有")
    @GetMapping("/list")
    public Result list() {
        return shopService.list();
    }
}